<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "current_toilet".
 *
 * @property int $id
 * @property int $t_id
 * @property int $tem
 * @property int $hum
 * @property int $gas
 * @property int $seats
 * @property int $unuse
 * @property int $all
 * @property int $flow
 * @property string $time
 * @property int $status
 *
 * @property Toilet $t
 */
class CurrentToilet extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'current_toilet';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['id', 't_id', 'tem', 'hum', 'gas', 'unuse', 'all', 'flow'], 'required'],
            [['id', 't_id', 'tem', 'hum', 'gas', 'seats', 'unuse', 'all', 'flow', 'status'], 'integer'],
            [['time'], 'safe'],
            [['id'], 'unique'],
            [['t_id'], 'exist', 'skipOnError' => true, 'targetClass' => Toilet::className(), 'targetAttribute' => ['t_id' => 't_id']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            't_id' => '厕所编号',
            'tem' => '温度(°C)',
            'hum' => '湿度(%',
            'gas' => '气体',
            'seats' => '蹲位数',
            'unuse' => '未使用',
            'all' => '蹲位状态',
            'flow' => '人流量',
            'time' => '更新时间',
            'status' => '状态',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getT()
    {
        return $this->hasOne(Toilet::className(), ['t_id' => 't_id']);
    }
}
